#include<bits/stdc++.h>
using namespace std;

void solve(){
	int n,m,L,V;
	cin >> n >> m >> L >> V;
	vector<pair<double, double>> car;
	car.reserve(n);
	for(int i = 0; i < n; i++){
		int d,v,a;
		cin >> d >> v >> a;

		if(!a){
			if(v > V)
				car.push_back({d, L});
		}
		else if(a > 0){
			if(v > V)
				car.push_back({d, L});
			else if(d + (V * V - v * v) / (2. * a) < L)
				car.push_back({d + (V * V - v * v) / (2. * a) + 1e-2, L});
		}
		else if(v > V)
			car.push_back({d, d + (v * v - V * V) / (-2. * a) - 1e-2});
	}

	vector<int> p(m);
	for(int& q : p)
		cin >> q;

	sort(p.begin(), p.end());
	sort(car.begin(), car.end(), [](const pair<double, double>& a, const pair<double, double>& b){
		return a.second < b.second;
	});
	vector<bool> vis(car.size());

	int cnt1 = 0, cnt2 = 0, l = 0;
	for(int i = 0; i < int(car.size()); i++){
		int it = lower_bound(p.begin(), p.end(), car[i].first) - p.begin();
		if(it < m && p[it] <= car[i].second)
			cnt1 += vis[i] = 1;
	}
	vector<bool> vis_(p.size());
	int pre = -1;
	for(int i = 0; i < int(car.size()); i++){
		if(pre != -1 && (car[i].first <= p[pre] && p[pre] <= car[i].second))
			continue;
		int it = lower_bound(p.begin(), p.end(), car[i].second) - p.begin() - 1;
		if(it >= 0 && car[i].first <= p[it])
			cnt2 += !vis_[i], vis_[i] = 1, pre = it;
	}

	cout << cnt1 << ' ' << m - cnt2 << '\n';
}

int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	freopen("detect.in","r",stdin);
	freopen("detect.out","w",stdout);

	int t;
	cin >> t;
	while(t--)
		solve();

	return 0;
}